package com.example.demo.service.impl;

import com.example.demo.entity.User;
import com.example.demo.service.LoginService;
import com.example.demo.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class LoginServiceImpl implements LoginService {
    @Autowired
    UserService userService;
    @Override
    public User login(User user) {
        if(user == null) return null;
        User userByName = userService.getUserByName(user.getUsername());
        if (userByName == null) return null;
        boolean equals = userByName.getPassword().equals(user.getPassword());
        if(equals == true) return user;
        else return null;
    }
}
